package com.graduation.fq.teacher.logic;

import com.graduation.fq.teacher.interfaces.EventListener;
import com.graduation.fq.teacher.interfaces.ResponseListener;
import com.graduation.fq.teacher.module.EventArgs;
import com.graduation.fq.teacher.module.StudentInfo;
import com.graduation.fq.teacher.process.ScoreUpdateProcess;

/**
 * @author jifang
 * @version 2016/5/24.
 */
public class ScoreLogic extends BaseLogic {
    private static ScoreLogic instance;

    public static ScoreLogic getInstance() {
        if (instance == null) {
            instance = new ScoreLogic();
        }
        return instance;
    }

    public void updateScore(StudentInfo info, String courseId, final EventListener listener) {
        final ScoreUpdateProcess process = new ScoreUpdateProcess();
        process.setStudentId(info.getId());
        process.setCourseId(courseId);
        process.setScore(info.getScore());
        process.runGet(new ResponseListener() {
            @Override
            public void onResponse(String requestId) {
                EventArgs args = new EventArgs(process.getStatus());
                fireEvent(args, listener);
            }
        });
    }
}
